package Library.operation;

import Library.Book;
import Library.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("借书");
        Scanner scanner = new Scanner(System.in);
        int id = scanner.nextInt();
        if(id < 0 || id > bookList.getSize() -1){
            System.out.println("编号不存在");
            return;
        }
        Book book = bookList.getBook(id);
        if(book.isBorrow()){
            System.out.println("该书已被借出");
            return;
        }
        book.setBorrow(true);
        System.out.println("借书成功");


    }
}
